package abs.service;

import abs.domain.Companias;
import abs.domain.Retenciones;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/absWeb-security-context.xml",
		"file:./resources/absWeb-service-context.xml",
		"file:./resources/absWeb-dao-context.xml",
		"file:./resources/absWeb-web-context.xml" })
@Transactional
public class RetencionesServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected RetencionesService service;

	/**
	 * Instantiates a new RetencionesServiceTest.
	 *
	 */
	public RetencionesServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing Companias entity
	 * 
	 */
	@Test
	public void saveRetencionesCompanias() {
		// TODO: JUnit - Populate test inputs for operation: saveRetencionesCompanias 
		String rt100cdgo = null;
		Companias related_companias = new abs.domain.Companias();
		Retenciones response = null;
		response = service.saveRetencionesCompanias(rt100cdgo, related_companias);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRetencionesCompanias
	}

	/**
	 * Operation Unit Test
	 * Return all Retenciones entity
	 * 
	 */
	@Test
	public void findAllRetencioness() {
		// TODO: JUnit - Populate test inputs for operation: findAllRetencioness 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Retenciones> response = null;
		response = service.findAllRetencioness(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllRetencioness
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Retenciones entity
	 * 
	 */
	@Test
	public void deleteRetenciones() {
		// TODO: JUnit - Populate test inputs for operation: deleteRetenciones 
		Retenciones retenciones = new abs.domain.Retenciones();
		service.deleteRetenciones(retenciones);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findRetencionesByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findRetencionesByPrimaryKey 
		String rt100cdgo_1 = null;
		Retenciones response = null;
		response = service.findRetencionesByPrimaryKey(rt100cdgo_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findRetencionesByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Companias entity
	 * 
	 */
	@Test
	public void deleteRetencionesCompanias() {
		// TODO: JUnit - Populate test inputs for operation: deleteRetencionesCompanias 
		String retenciones_rt100cdgo = null;
		String related_companias_co000nocia = null;
		Retenciones response = null;
		response = service.deleteRetencionesCompanias(retenciones_rt100cdgo, related_companias_co000nocia);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRetencionesCompanias
	}

	/**
	 * Operation Unit Test
	 * Load an existing Retenciones entity
	 * 
	 */
	@Test
	public void loadRetencioness() {
		Set<Retenciones> response = null;
		response = service.loadRetencioness();
		// TODO: JUnit - Add assertions to test outputs of operation: loadRetencioness
	}

	/**
	 * Operation Unit Test
	 * Save an existing Retenciones entity
	 * 
	 */
	@Test
	public void saveRetenciones() {
		// TODO: JUnit - Populate test inputs for operation: saveRetenciones 
		Retenciones retenciones_1 = new abs.domain.Retenciones();
		service.saveRetenciones(retenciones_1);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Retenciones entity
	 * 
	 */
	@Test
	public void countRetencioness() {
		Integer response = null;
		response = service.countRetencioness();
		// TODO: JUnit - Add assertions to test outputs of operation: countRetencioness
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
